package com.example.mapreduce.outputformat;

import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * ClassName: LogReduce
 * Package: com.example.mapreduce.outputformat
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-07-16
 * Time: 20:25
 */

public class LogReduce extends Reducer<Text, NullWritable,Text,NullWritable> {

    @Override
    protected void reduce(Text key, Iterable<NullWritable> values, Context context) throws IOException, InterruptedException {

        //如果是两条一样的数据 可能存在数据丢失 reduce处理相同的key
        //map是把数据作为key值传递了
        //所以要循环的遍历一下
        for (NullWritable value : values) {
            context.write(key,NullWritable.get());
        }

    }
}
